/**
 *
 */
package com.hexacta.hrs.services.staffing.impl.predicates;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.collections.Predicate;

import com.hexacta.hrs.domain.staffing.assignment.EmployeeAssignment;

/**
 * @author ldeveikis
 * 
 */
public class AssignmentRolePredicate implements Predicate {

    private List<String> codes;

    private AssignmentRolePredicate() {
    }

    public AssignmentRolePredicate(final List<String> codes) {
        if (codes != null) {
            this.codes = codes;
        } else {
            this.codes = new ArrayList<String>();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
     */
    @Override
    public boolean evaluate(final Object object) {
        return object instanceof EmployeeAssignment
                && codes.contains(((EmployeeAssignment) object).getAssignedRole().getCode());
    }

}
